<?php

namespace app\api\controller\v1;

use app\api\validate\UploadFileValidate;
use Eadmin\Admin;
use Eadmin\Controller;
use think\Request;

/**
 * 公共
 */
class Common extends Controller
{
    /**
     * 上传文件
     * @param UploadFileValidate $validate
     * @return \think\response\Json
     */
    public function postUpload(UploadFileValidate $validate){
        $file  = $this->request->file('file');
        $url = Admin::file()->upload($file,null,'',config('admin.uploadDisks'),true);
        if($url === false){
            return json(['code' => 5005, 'message' => '上传失败']);
        }else{
            return json(['code' => 200, 'data' => $url]);
        }
    }
}
